﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

namespace WebApp
{
    public partial class ViewProfile : System.Web.UI.Page
    {
        string strConnect;
        SqlConnection con;
        SqlCommand cmd;
        SqlDataAdapter da;
        DataSet ds;

        protected void Page_Load(object sender, EventArgs e)
        {
            strConnect = "Data Source = (local); Database =ProjectSem3; User id = sa; Password = 30041975";
            con = new SqlConnection(strConnect);
            ds = new DataSet();
            if (!Page.IsPostBack)
            {
                try
                {
                    lblname.Text = Application["userid"].ToString();
                    guestid.Text = Request.Cookies["login"]["guestno"];
                    //lblDuration.Text = "-";
                    //lblFee.Text = "-";
                    Bindcus();
                }
                catch (Exception ex)
                {
                    Response.Write(ex.Message);
                }
            }
        }
        protected void Bindcus()
        {
            try
            {
                lblname.Text = Application["userid"].ToString();
                if (con.State == ConnectionState.Closed)
                    con.Open();
                string q = "select * from customer where username = '" + lblname.Text + "'"  ;
                cmd = new SqlCommand(q, con);
                cmd.CommandType = CommandType.Text;
                da = new SqlDataAdapter(cmd);
                da.Fill(ds, "customer");
                GridView1.DataSource = ds.Tables[0];
                GridView1.DataBind();


            }
            catch (SqlException ex)
            {
                //throw new Exception(ex.Message);
            }
            finally
            {
                con.Close();
            }
        }

        protected void btnOK_Click(object sender, EventArgs e)
        {
            Response.Redirect("Home.aspx");
        }
    }
}